import erniebot


# 初始化 Erniebot
def initialize_erniebot():
    erniebot.api_type = 'aistudio'
    erniebot.access_token = '721efe09951433260c4ab297c2830cffc82e2d77'


def abstract(user_query):
    initialize_erniebot()

    question = f"""
    生成以下内容的100字摘要：{user_query}
    """

    response = erniebot.ChatCompletion.create(
        model='ernie-3.5',
        messages=[
            {'role': 'user', 'content': question},
        ],
        temperature=0.2
    )

    return response.get_result()

# 调用方式示例（在其他文件中，首先要导入这个函数）
# user_question = input()
# result = abstract(user_question)
# print(result)
